import request from '@/utils/request'

export function getGroupbuyUsableList(query) {
  let baseUrl = "/marketing/groupbuy"
  if(query != undefined){
    if(typeof query == "object"){
      console.log(query)
      if(query.hasOwnProperty('groupbuyID')){
        query['groupbuyID'] = parseInt(query['groupbuyID'])
        if(isNaN(query['groupbuyID']) == false){
          baseUrl = baseUrl+"-"+query['groupbuyID']
        }
      }
    }
  }
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export function getGroupbuyList(query) {
  return request({
    url: '/marketing/admin/groupbuy/getList',
    method: 'post',
    data: query
  })
}
export function saveGroupbuy(query) {
  return request({
    url: '/marketing/admin/groupbuy/save',
    method: 'post',
    data: query
  })
}

export function removeGroupbuy(query) {
  return request({
    url: '/marketing/admin/groupbuy/remove',
    method: 'post',
    data: query
  })
}
export function getGroupbuyDetail(query) {
  if(query != undefined){
    query = JSON.parse(JSON.stringify(query))
  }
  return request({
    url: '/marketing/admin/groupbuy/info/0',
    method: 'get',
    data: query
  })
}